package com.example.dicomviewer.reconstruction;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.example.dicomviewer.R;
import com.example.dicomviewer.core.DataArray;

public class Reconstruction extends AppCompatActivity {
    private final static String TAG = "Reconstruction";
    private MyGLSurfaceView glSurfaceView;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.change_visualization, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.visalBone:
                glSurfaceView.changeViewType(DataArray.BONE);
                break;
            case R.id.visalViscera:
                glSurfaceView.changeViewType(DataArray.VISCERA);
                break;
            case R.id.reset:
                glSurfaceView.reset();
                break;
        }
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reconstruction);
        Log.d(TAG, "DataArray is null? : " + (DataArray.getInstance() == null));
        glSurfaceView = new MyGLSurfaceView(this);
        setContentView(glSurfaceView);
    }

    private boolean detectOpenGLES30() {
        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        String resulr = Integer.toString(info.reqGlEsVersion, 16);
        return (info.reqGlEsVersion >= 0x30000);
    }
}